package com.flurry.android;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.text.TextUtils;
import android.util.Log;
import java.util.HashSet;
import java.util.UUID;

public class CacheSearchData extends al
{
  private static String TAG = "CacheSearchData";

  public CacheSearchData(Context paramContext, String paramString)
  {
    this.cD = dw.e(paramContext, paramString);
    this.cE = "searchRequestsTable";
  }

  public String addItem(String paramString1, String paramString2, long paramLong)
  {
    Log.d(TAG, "--- Insert in " + this.cE + ": ---");
    SQLiteDatabase localSQLiteDatabase = this.cD.getWritableDatabase();
    ContentValues localContentValues = new ContentValues();
    String str = UUID.randomUUID().toString();
    localContentValues.put("searchPredicat", paramString1);
    localContentValues.put("collectionName", paramString2);
    localContentValues.put("timestamp", Long.valueOf(paramLong));
    localContentValues.put("objectsId", str);
    long l = localSQLiteDatabase.insert(this.cE, null, localContentValues);
    Log.d(TAG, "row inserted, ID = " + l);
    readAll();
    return str;
  }

  public String contains(String paramString1, String paramString2)
  {
    Cursor localCursor = this.cD.getReadableDatabase().query(this.cE, null, "searchPredicat='" + paramString1 + "'", null, null, null, null);
    boolean bool = localCursor.moveToFirst();
    Object localObject = null;
    String str1;
    String str2;
    if (bool)
    {
      int i = localCursor.getColumnIndex("objectsId");
      int j = localCursor.getColumnIndex("collectionName");
      str1 = localCursor.getString(i);
      str2 = localCursor.getString(j);
      if ((!TextUtils.isEmpty(str2)) || (!TextUtils.isEmpty(paramString2)))
        break label128;
      localObject = str1;
    }
    while (true)
    {
      localCursor.close();
      return localObject;
      label128: if ((str2 != null) && (paramString2 != null) && (str2.equals(paramString2)))
      {
        localObject = str1;
      }
      else
      {
        if (localCursor.moveToNext())
          break;
        localObject = null;
      }
    }
  }

  public Object[] getIdsAssociatedWithCollectionName(String paramString)
  {
    SQLiteDatabase localSQLiteDatabase = this.cD.getReadableDatabase();
    HashSet localHashSet = new HashSet();
    Cursor localCursor = localSQLiteDatabase.query(this.cE, null, "collectionName='" + paramString + "'", null, null, null, null);
    if (localCursor.moveToFirst())
    {
      int i = localCursor.getColumnIndex("objectsId");
      do
        localHashSet.add(localCursor.getString(i));
      while (localCursor.moveToNext());
    }
    localCursor.close();
    return localHashSet.toArray();
  }

  public void readAll()
  {
    Cursor localCursor = this.cD.getReadableDatabase().query(this.cE, null, null, null, null, null, null);
    if (localCursor.moveToFirst())
    {
      int i = localCursor.getColumnIndex("searchPredicat");
      int j = localCursor.getColumnIndex("collectionName");
      int k = localCursor.getColumnIndex("timestamp");
      int m = localCursor.getColumnIndex("objectsId");
      do
        Log.w(TAG, "predicat = " + localCursor.getString(i) + ", collection_name = " + localCursor.getString(j) + ", timestamp = " + localCursor.getString(k) + ", id = " + localCursor.getString(m));
      while (localCursor.moveToNext());
    }
    while (true)
    {
      localCursor.close();
      return;
      Log.w(TAG, "TABLE IS EMPTY");
    }
  }

  public void removeByCollectionName(String paramString)
  {
    this.cD.getWritableDatabase().delete(this.cE, "collectionName='" + paramString + "'", null);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.flurry.android.CacheSearchData
 * JD-Core Version:    0.6.2
 */